<?php

namespace app\admin\controller;
use app\common\controller\Jwts;
use app\common\model\Syslog;
class Index
{
    public  function  noright()
    {
        // Session::set('uid','aa');
        $msg=input('msg');
        $meta=[
            'msg'=>$msg,
            'status'=>-1
        ];
        $res=[
            'data'=>'',
            'meta'=>$meta
        ];
        return json($res);

    }
    public function login()
    {  //登录检测
        $uname=input('post.username');
        $upass=input('post.password');
        if ($uname=="admin" &&  $upass=="123"){

            $myjwt = new Jwts();
            $uid='ozyKc1VofW8tEoiFGwIV8NR4U_kA';
            $token=$myjwt->signToken($uid);
            $data=[
                'id'=>$uid,
                'name'=>'管理员',
                'avatar'=>'http://172.18.42.200/static/mp3/logo.png',
                'mobile'=>'130',
                'token'=>$token
            ];
           // session('user',$SessionData);
          //  $data=session('user');
            $ip= request()->ip();
            $res = Syslog::create([
            'ip' => $ip,
            'caozuo' => '登录'           
            ]);
            $msg='登录成功';
            $status=200;
        }else{
            $data=[
            ];
            $msg="用户名或密码错误";
            $status=0;
        }
        $meta=[
            'msg'=>$msg,
            'status'=>$status
        ];
        $res=[
            'data'=>$data,
            'meta'=>$meta
        ];
        return json($res);
    }
}
